<?php

namespace app\tours\controller;

class Pub extends Common {

        public function validation() {
                $name = I('name');
                switch ($name) {
                        case "username":
                                $email = I('param');
                                if (M("User")->where(array('email' => $email))->getField("id")) {
                                        $this->ajaxReturn("", "正确", "y");
                                } else {
                                        $this->ajaxReturn("", "邮箱不存在", "n");
                                }
                                break;
                        case "verify":
                                $verify = I('param');
                                $verifys = new \org\Verify();
                                if (!$verifys->check($verify, "tours")) {
                                        $this->ajaxReturn("", "验证码错误", "n");
                                } else {
                                        $this->ajaxReturn("", "正确", "y");
                                }
                                break;
                        default:

                                break;
                }
        }

        /**
          +----------------------------------------------------------
         * 显示验证码
          +----------------------------------------------------------
         */
        public function verify() {
                $config = array(
                    'fontSize' => 12, // 验证码字体大小    
                    'length' => 4, // 验证码位数    
                    'useNoise' => false, // 关闭验证码杂点
                    'imageW' => 110,
                    'imageH' => 42,
                    'codeSet' => '0123456789',
                    'fontSize' => 16,
                    'fontttf' => '4.ttf'
                );
                $Verify = new \org\Verify($config);
                $Verify->entry('tours');
        }

}
